-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/524/weights in beta #532
Conversation
@marina-ricci Is this what you were thinking about? Let me know if you want something different. |
[from 25/11/2022 tag-up]: wait for PR #517 |
@m-aguena I think everything is working now. I added the option of the user to provide shape weights for the source galaxies. If you can take a look if this is what you want please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall is ok. I made comments in specific lines, but they apply to several modifications.
clmm/utils.py
Outdated
@@ -782,8 +782,7 @@ def integrand(z_i, z_cl=z_cl, cosmo=cosmo): | |||
B_mean = quad(integrand, zmin, zmax)[0] / quad(z_distrib_func, zmin, zmax)[0] | |||
return B_mean | |||
|
|||
def compute_beta_s_mean(z_cl, z_inf, cosmo, zmax=10.0, delta_z_cut=0.1, zmin=None, | |||
z_distrib_func=None): | |||
def compute_beta_s_mean(z_cl, z_inf, cosmo, zmax=10.0, delta_z_cut=0.1, zmin=None, z_distrib_func=None, weights_option=False, z_src = None, shape_weights = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the weights_option
argument and just apply weight when shape_weights
is provided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
clmm/utils.py
Outdated
zmin = z_cl + delta_z_cut | ||
Bs_mean = quad(integrand, zmin, zmax)[0] / quad(z_distrib_func, zmin, zmax)[0] | ||
if weights_option == False: | ||
if z_distrib_func == None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use is None
instead of == None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
clmm/utils.py
Outdated
else: | ||
n_galaxies = len(z_src) | ||
weight = 1/n_galaxies | ||
Bsw_i = [shape_weights[i] * compute_beta_s(z_src[i], z_cl, z_inf, cosmo) for i in range(0,len(z_src))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe a simple vector product can be used here shape_weights * compute_beta_s(z_src, z_cl, z_inf, cosmo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
To change that, I had to change compute_beta
to accept a list of sources instead of being called to compute each source at a time. I changed the documentation for z_source: float, array_like
, but if the user passes a scalar just for one source, I'm transforming into a one argument list.
clmm/utils.py
Outdated
beta = np.heaviside(z_src-z_cl, 0) * cosmo.eval_da_z1z2(z_cl, z_src) / cosmo.eval_da(z_src) | ||
return beta | ||
if type(z_src) is not list: | ||
z_src = [z_src] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I should keep this test or expect the user to pass a list with just one source. @m-aguena
@combet @marina-ricci @eduardojsbarroso I was checking this use, and to sum up we have two possible ways of computing My suggestion here is to just have different functions (ex: Then we have two options for how this will be used in the theory functions (ex:
Opinions? |
I think the second option is better than to having the users to compute themselves. |
I actually think we can live with option 1 (for which we do not have to make modifications) for the time being. I think it would be cleaner that way. |
@m-aguena tell me if this was what you were thinking when you have time, please. |
@m-aguena Do you know why is the test failling? The tets work in my computer. |
@eduardojsbarroso yes, it has to do with CCL's new version. PR #593 should fix it |
@eduardojsbarroso They should be removed from the notebooks. Now, beta should be computed by the user and passed to these function, and this should be reflected on the notebooks |
…e_beta_s_mean*_from_weights
@combet @marina-ricci can one of you guys take a final look before I merge this? I would like a second pair of eyes on it since there are some API changes. The main implementation was the suggestion here #532 (comment) But I also ended up adding the functions Thanks! |
f13e36e
to
5e8af97
Compare
* distinguish between compute_beta_s_*_from_distribution and compute_beta_s_*_from_weights * make compute_beta more efficient and fix shape_weights=None in compute_beta_s_mean*_from_weights * add _eval_da, _eval_da_z1z2, _get_z_from_a, _get_a_from_z to cosm * reorder funcs in cosmo parent * add fix to skip pylint for astropy.units (fails in astropy 6) * Update version to 1.12.0 --------- Co-authored-by: m-aguena <[email protected]>
Include weights in beta measurements #524